//
//  TKSingleViewController.m
//  装修管家
//
//  Created by 千锋 on 16/1/21.
//  Copyright (c) 2016年 IOS1503薛凯. All rights reserved.
//

#import "TKSingleViewController.h"
#import "TKTopicViewController.h"
#import "TKRootViewController.h"
@interface TKSingleViewController ()
@property (weak, nonatomic) IBOutlet UISegmentedControl *segment;
@property (weak, nonatomic) IBOutlet UIView *fenggeView;
@property (weak, nonatomic) IBOutlet UIView *kongjianView;
@property (weak, nonatomic) IBOutlet UIView *jubuView;
@property (weak, nonatomic) IBOutlet UIView *yanseView;
@property (strong,nonatomic)UIView* FlagView;
@end

@implementation TKSingleViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
     self.segment.selectedSegmentIndex=1;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _fenggeView.hidden=YES;
    _kongjianView.hidden=YES;
    _jubuView.hidden=YES;
    _yanseView.hidden=YES;
   
    // Do any additional setup after loading the view from its nib.
}

- (IBAction)kongjianClick:(UIButton *)sender {
    if (_FlagView!=_kongjianView) {
        _FlagView.hidden=YES;
        _FlagView=_kongjianView;
    }
    _kongjianView.hidden=!_kongjianView.hidden;
}
- (IBAction)fenggeClick:(UIButton *)sender {
    if (_FlagView!=_fenggeView) {
        _FlagView.hidden=YES;
        _FlagView=_fenggeView;
    }
    _fenggeView.hidden=!_fenggeView.hidden;
}
- (IBAction)yanseClick:(UIButton *)sender {
    if (_FlagView!=_yanseView) {
        _FlagView.hidden=YES;
        _FlagView=_yanseView;
    }
    _yanseView.hidden=!_yanseView.hidden;
}
- (IBAction)jubuClick:(UIButton *)sender {
    if (_FlagView!=_jubuView) {
        _FlagView.hidden=YES;
        _FlagView=_jubuView;
    }
    _jubuView.hidden=!_jubuView.hidden;
}
- (IBAction)segmentChange:(UISegmentedControl *)sender {
    switch (sender.selectedSegmentIndex) {
        case 0:
        {
            int num=0;
            for (UIViewController* view in self.navigationController.viewControllers) {
                if ([view isKindOfClass:[TKRootViewController class]]) {
                    [self.navigationController popToViewController:view animated:NO];
                    
                    num=1;
                }
            }
            if (num==0) {
                TKRootViewController* root=[[TKRootViewController alloc] init];
                [self.navigationController pushViewController:root animated:NO];
            }
            break;
        }
        case 2:
        {
            int num=0;
            for (UIViewController* view in self.navigationController.viewControllers) {
                if ([view isKindOfClass:[TKTopicViewController class]]) {
                    [self.navigationController popToViewController:view animated:NO];
                    
                    num=1;
                }
            }
            if (num==0) {
                TKTopicViewController* topic=[[TKTopicViewController alloc] init];
                [self.navigationController pushViewController:topic animated:NO];
            }
            break;
        }
            
        default:
            break;
    }
}


@end
